<?php

/*

  Action – Prize	$0*

  +1 Buy
  While this is in play, cards cost $2 less, but not less than $0.

 */

class Princess extends Card implements iAction, iPrize, iInfluence {

    public function __construct() {
        parent::__construct("Princess", 0);
        $this->undoPlay = false;
        $this->undoBuy = false;
    }

    public function getDescription() {
        return array(
            "+1 Buy",
            "While this is in play, cards cost $2 less, but not less than $0.");
    }
    
    public function play(Game $game, $isRealCard) {
        $game->addBuys(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1$", "gets +1$");

        if ($isRealCard == REAL_CARD) {
            $game->pushCardToInfluence($this);
            $this->influence($game);
        }
    }

    public function influence(Game $game) {
        $names = $game->getPlayersNames();
        foreach ($names as $name) {
            $cards = $game->getAllCards($name);
            foreach ($cards as $card) {
                $price = $card->getPrice($game);
                $new_price = $price->add(-2);
                $card->setPrice($new_price);
            }
        }
        $boardCards = $game->getBoardCardsByPrice();
        foreach ($boardCards as $card) {
            $price = $card->getPrice($game);
            $new_price = $price->add(-2);
            $card->setPrice($new_price);
        }
    }

}

?>